#define _CRT_SECURE_NO_WARNINGS 1
#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 9;
#define x first
#define y second
typedef long long ll;
pair<int, int>p[N];
ll pre[N], nex[N];
int main()
{
    int n;cin >> n;
    for (int i = 1;i <= n;i++)cin >> p[i].y >> p[i].x;
    sort(p + 1, p + 1 + n);
    ll s = 0;
    for (int i = 1;i <= n;i++) {
        pre[i] = pre[i - 1];
        pre[i] += s * (p[i].x - p[i - 1].x);
        s += p[i].y;
    }
    s = 0;
    for (int i = n;i >= 1;i--) {
        nex[i] = nex[i + 1];
        nex[i] += s * (p[i + 1].x - p[i].x);
        s += p[i].y;
    }
    ll ans = 1e18;
    for (int i = 1;i <= n;i++) {
        ans = min(ans, pre[i] + nex[i]);
    }
    cout << ans << endl;
    return 0;
}